package com.ruoyi.kenuo.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.kenuo.domain.KernelFkReply;
import com.ruoyi.kenuo.service.IKernelFkReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 意见反馈Controller
 *
 * @author polo
 * @date 2022-10-17
 */
@RestController
@RequestMapping("/kenuo/reply")
@Api(tags = "意见反馈回复")
public class KernelFkReplyController extends BaseController
{
    @Autowired
    private IKernelFkReplyService kernelFkReplyService;

    /**
     * 查询意见反馈列表
     */
    @ApiOperation(value="获取反馈回复的列表", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "remarkOne", value = "反馈id", required = true, dataType = "String")
    })
    @GetMapping("/list")
    public TableDataInfo list(KernelFkReply kernelFkReply)
    {
        startPage();
        List<KernelFkReply> list = kernelFkReplyService.selectKernelFkReplyList(kernelFkReply);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KernelFkReply kernelFkReply)
    {
        List<KernelFkReply> list = kernelFkReplyService.selectKernelFkReplyList(kernelFkReply);
        ExcelUtil<KernelFkReply> util = new ExcelUtil<KernelFkReply>(KernelFkReply.class);
        util.exportExcel(response, list, "意见反馈数据");
    }

    /**
     * 获取意见反馈详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(kernelFkReplyService.selectKernelFkReplyById(id));
    }

    /**
     * 新增意见反馈回复
     */
    @ApiOperation(value="新增意见反馈回复", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "replyContent", value = "回复内容", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "remarkOne", value = "反馈的id", required = true, dataType = "String")
    })
    @Log(title = "意见反馈回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KernelFkReply kernelFkReply)
    {
        return toAjax(kernelFkReplyService.insertKernelFkReply(kernelFkReply));
    }

    /**
     * 修改意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KernelFkReply kernelFkReply)
    {
        return toAjax(kernelFkReplyService.updateKernelFkReply(kernelFkReply));
    }

    /**
     * 删除意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kernelFkReplyService.deleteKernelFkReplyByIds(ids));
    }
}
